package com.xjz.model.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * ClassName: JudgeInfoMessageEnum
 * Package: com.xjz.model.enums
 * Description:
 *
 * @Author 许小健
 * @Create 2025/8/16 23:20
 * @Version 1.0
 */
@Getter
public enum JudgeInfoMessageEnum {
    ACCEPTED("成功", "Accepted"),
    WRONG_ANSWER("答案错误", "Wrong Answer"),
    COMPILE_ERROR("编译错误", "Compile Error"),
    MEMORY_LIMIT_EXCEEDED("内存溢出", "Memory Limit Exceeded"),
    TIME_LIMIT_EXCEEDED("超时", "Time Limit Exceeded"),
    PRESENTATION_ERROR("展示错误", "Presentation Error"),
    WAITING("等待中", "Waiting"),
    OUTPUT_LIMIT_EXCEED("输出溢出", "Output Limit Exceeded"),
    DANGEROUS_OPERATION("危险操作", "Dangerous Operation"),
    RUNTIME_ERROR("运行错误", "Runtime Error"),
    SYSTEM_ERROR("系统错误", "System Error");

    private final String text;

    private final String value;

    JudgeInfoMessageEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }


    public static List<String> getValues() {
        return Arrays.stream(values()).map(JudgeInfoMessageEnum::getValue).collect(Collectors.toList());
    }

    /**
     * 根据value获取枚举对象
     *
     * @param value
     * @return
     */
    public static JudgeInfoMessageEnum getEnumByValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }

        for (JudgeInfoMessageEnum judgeInfoMessageEnum : values()) {
            if (judgeInfoMessageEnum.value.equals(value)) {
                return judgeInfoMessageEnum;
            }
        }

        return null;
    }
}
